package com.dongdongsop.controller;

import com.dongdongshop.data.Result;
import com.dongdongshop.em.ResultEnum;
import com.dongdongshop.pojo.TbContent;
import com.dongdongshop.service.TbContentService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("image")
public class TbContentController {

    @DubboReference
    private TbContentService tbContentService;

    @RequestMapping("lunbo")
    @ResponseBody
    public Result lunbo(Integer id) {
        List<TbContent> tbContents = tbContentService.selectByLunBo(id);
        if (tbContents == null) {
            return Result.response(ResultEnum.ERROR);
        }
        return Result.response(ResultEnum.SUCCESS).setData(tbContents);
    }

    @RequestMapping("jinri")
    @ResponseBody
    public Result jinri(Integer id) {
        List<TbContent> tbContents = tbContentService.selectByjinri(id);
        if (tbContents == null) {
            return Result.response(ResultEnum.ERROR);
        }
        return Result.response(ResultEnum.SUCCESS).setData(tbContents);
    }

    @RequestMapping("getLike")
    @ResponseBody
    public Result getLike(Integer id) {
        List<TbContent> tbContents = tbContentService.selectByLike(id);
        if (tbContents == null) {
            return Result.response(ResultEnum.ERROR);
        }
        return Result.response(ResultEnum.SUCCESS).setData(tbContents);
    }

    @RequestMapping("getYouqu")
    @ResponseBody
    public Result getYouqu(Integer id) {
        List<TbContent> tbContents = tbContentService.selectByYouQu(id);
        if (tbContents == null) {
            return Result.response(ResultEnum.ERROR);
        }
        return Result.response(ResultEnum.SUCCESS).setData(tbContents);
    }

    @RequestMapping("getFloor")
    @ResponseBody
    public Result getFloor(Integer id) {
        List<TbContent> tbContents = tbContentService.selectByFloor(id);
        if (tbContents == null) {
            return Result.response(ResultEnum.ERROR);
        }
        return Result.response(ResultEnum.SUCCESS).setData(tbContents);
    }
@RequestMapping("getFloor2")
    @ResponseBody
    public Result getFloor2(Integer id) {
        List<TbContent> tbContents = tbContentService.selectByFloor2(id);
        if (tbContents == null) {
            return Result.response(ResultEnum.ERROR);
        }
        return Result.response(ResultEnum.SUCCESS).setData(tbContents);
    }

}
